package com.design.movieticket.controller;

import com.design.movieticket.common.base.constant.Result;
import com.design.movieticket.common.base.constant.ResultStatus;
import com.design.movieticket.dto.HallListDto;
import com.design.movieticket.entity.MovieArrange;
import com.design.movieticket.service.MovieArrangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Slf4j
@Api(tags = "排片管理")
@RestController
@RequestMapping("/movieArrange")
public class MovieArrangeController {
    @Resource
    private MovieArrangeService movieArrangeService;

    @ApiOperation("场次列表")
    @PostMapping("/getTableData")
    public Result getTableData(String movieName, Long hallId, String date){
        List<MovieArrange> tableData = movieArrangeService.getTableData(movieName, hallId, date);
        return new Result(tableData, ResultStatus.REQUEST_SUCCESS.getMsg(),ResultStatus.REQUEST_SUCCESS.getCode());
    }

    @ApiOperation("获取影厅列表")
    @GetMapping("/getHallList/{principalName}")
    public Result getHallList(@PathVariable String principalName){
        List<HallListDto> hallList = movieArrangeService.getHallList(principalName);
        return new Result(hallList, ResultStatus.REQUEST_SUCCESS.getMsg(),ResultStatus.REQUEST_SUCCESS.getCode());
    }

    @ApiOperation("新增场次")
    @PostMapping("/addMovieArrange")
    public Result addMovieArrange(@RequestBody MovieArrange movieArrange){
        movieArrangeService.addMovieArrange(movieArrange);
        return new Result(ResultStatus.SAVE_SUCCESS.getMsg(),ResultStatus.SAVE_SUCCESS.getCode());
    }

    @ApiOperation("撤销场次")
    @PostMapping("/removeMovieArrange/{movieArrangeId}")
    public Result getHallList(@PathVariable Long movieArrangeId){
        movieArrangeService.removeMovieArrange(movieArrangeId);
        return new Result(ResultStatus.DELETE_SUCCESS.getMsg(),ResultStatus.DELETE_SUCCESS.getCode());
    }



    @GetMapping("/wxGetMovieArrangeListByCinemaIdAndMovieName")
    public Result wxGetMovieArrangeListByCinemaIdAndMovieName(Long cinemaId, String nowTime, String movieName){
        return new Result(movieArrangeService.wxGetMovieArrangeListByCinemaIdAndMovieName(cinemaId, nowTime, movieName),ResultStatus.REQUEST_SUCCESS.getMsg(),ResultStatus.REQUEST_SUCCESS.getCode());
    }
}
